package com.fit.pages.card;

import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;

import com.fit.annotations.AdminAccess;
import com.fit.annotations.AnonymousAccess;
import com.fit.annotations.CoachAccess;
import com.fit.dao.card.CardDAO;
import com.fit.entities.card.Card;

import com.fit.pages.ErrorPage;

@AdminAccess
@CoachAccess
@AnonymousAccess
public class Add {

	@Property
	private Card card;
	@Inject
	private CardDAO cardDAO;
	@InjectPage
	private ErrorPage errorPage;

	Object onSuccess() {
		try {
			
			cardDAO.save(card);
			return Browse.class;
		} catch (Exception e) {
			errorPage.setMessage(" Error while adding new CARD! ");
			return errorPage;
		}

	}
}
